package com.spring.boot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spring.boot.entity.SysMenu;
import com.spring.boot.entity.SysRole;
import com.spring.boot.mapper.SysMenuMapper;
import com.spring.boot.mapper.SysRoleMapper;
import com.spring.boot.service.SysMenuService;
import com.spring.boot.service.SysRoleService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
    @Override
    public String translate(String menus) {
        String[] menuArr = menus.split(",");
        List<String> descrArr = new ArrayList<>();
        for (String menu : menuArr) {
            SysMenu sysMenu = super.getOne(new LambdaQueryWrapper<SysMenu>()
                    .eq(SysMenu::getMenu, menu.replace("ROLE_","")));
            String descr = sysMenu.getDescr();
            descrArr.add(descr);
        }
        String descrArrStr = descrArr.toString();
        String result = descrArrStr.replace("[", "").replace("]", "");
        return result;
    }
}
